package com.springboot.chapter4;

import com.springboot.chapter4.intercept.MyInterceptor;
import com.springboot.chapter4.service.HelloService;
import com.springboot.chapter4.service.impl.HelloServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

/**
 * 作者：paopao
 * 版本：1.0
 */
@Component
public class testProxy {
    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext();
        HelloService helloService = new HelloServiceImpl();
        // 按约定获取proxy
        HelloService proxy = (HelloService) ProxyBean.getProxyBean(helloService, new MyInterceptor());
        proxy.sayHello("paopao");
        System.out.println("\n######################### name is null!! ######################");
        proxy.sayHello(null);
    }
}
